package com.minimalist.lindi.mapper;

import com.minimalist.common.entity.lindi.po.LindiPurchaseApplicationTownItem;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

/**
 * 林地指标交易平台_购买申请镇街购买项 映射层。
 *
 * @author 11987
 * @since 2025-07-01
 */
public interface LindiPurchaseApplicationTownItemMapper extends BaseMapper<LindiPurchaseApplicationTownItem>{

    /**
     * 根据购买申请ID查询镇街购买项列表
     *
     * @param purchaseApplicationId 购买申请ID
     * @return 镇街购买项列表
     */
    default List<LindiPurchaseApplicationTownItem> selectTownItemListByPurchaseApplicationId(Long purchaseApplicationId) {
        return selectListByQuery(QueryWrapper.create()
                .eq(LindiPurchaseApplicationTownItem::getPurchaseApplicationId, purchaseApplicationId));
    }

    /**
     * 根据购买申请ID删除镇街购买项
     *
     * @param purchaseApplicationId 购买申请ID
     * @return 删除数量
     */
    default int deleteTownItemsByPurchaseApplicationId(Long purchaseApplicationId) {
        return deleteByQuery(QueryWrapper.create()
                .eq(LindiPurchaseApplicationTownItem::getPurchaseApplicationId, purchaseApplicationId));
    }

}
